//
//  ApplyTransferredinVC.m
//  投融保
//
//  Created by 523 on 14-1-8.
//  Copyright (c) 2014年 木叶科技. All rights reserved.
//


#import "ApplyTransferredinVC.h"
#import "MYTransferredInVC.h"
#import "MoneyString.h"
#import "MBProgressHUD.h"
#import "UIImageView+WebCache.h"

@interface ApplyTransferredinVC ()

@end

@implementation ApplyTransferredinVC
extern NSDictionary *userInformation;
NSString *moneyhuaru;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.bgScrollview setContentSize:CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-120)];
    UITapGestureRecognizer *gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyboard)];
    [self.bgScrollview addGestureRecognizer:gesture];
    
    [self.bankImage setImageWithURL:[NSURL URLWithString:[userInformation valueForKey:@"banklog"]]];
    self.bankName.text=[userInformation valueForKey:@"bankName"];
    if (![[userInformation valueForKey:@"bankCardNo"] isEqual:[NSNull null]]) {
        NSString *str=[userInformation valueForKey:@"bankCardNo"];
        NSRange a={str.length-4,4};
        int result=[[str substringWithRange:a] intValue];
        self.lblLastCardNum.text=[NSString stringWithFormat:@"尾号%d 储蓄卡",result];
    }else
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:nil message:@"银汉卡号为空" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alert show];
    }
}

- (void)viewWillAppear:(BOOL)animated
{
    self.txtmoney.text=@"";
    self.lblCharMoney.text=@"";
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)agreedProtcel:(UIButton *)sender {
    if (sender.selected) {
        [sender setImage:[UIImage imageNamed:@"disagreed_icon"] forState:UIControlStateNormal];
        sender.selected=!sender.selected;
    }
    else
    {
        [sender setImage:[UIImage imageNamed:@"agreed_icon"] forState:UIControlStateSelected];
        sender.selected=!sender.selected;
    }
}

- (IBAction)btnSubmitAction:(UIButton *)sender {
    NSString *message;
    if (self.btnProtocol.selected) {
        if ([self.txtmoney.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length>0) {
            moneyhuaru=self.txtmoney.text;
            [self presentViewController:[MYTransferredInVC new] animated:NO completion:nil];
            return;
        }else
        {
            message=@"请输入划入金额";
        }
        
    }else
    {
        message=@"需要您同意授权委托书";
    }
    NSString *cancel=@"确定";
    ALERTVIEW(message, cancel);
    
   
}

- (IBAction)btnReturnAction:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    //根据输入金额设置大写金额
    self.lblCharMoney.text=[MoneyString moneyStringWithDigitStr:self.txtmoney.text];
}

- (void)closeKeyboard
{
//    [self.bgScrollview setContentOffset:CGPointMake(0, 0)];
    [self.view endEditing:YES];
}

#pragma mark-   -----------状态栏底色------
- (UIStatusBarStyle)preferredStatusBarStyle
{
    [self.view setBackgroundColor:[UIColor blackColor]];
    return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden
{
    return NO;
}
@end
